package contegor.scire.core;

import java.util.Collection;

/**
 * Processing any {@link Task} needs a 'point' to which forward the results of such processing. This interface
 * defines that return points. If the <code>ReturnPoint</code> is shared by more than one {@link Task},
 * then the implementation of this interface must be thread safe.
 *
 * @version $Revision: 1.2 $
 * @author  Héctor Cirbián Pousa ($Author: hector $)
 */
@Version("$Id$")
public interface ReturnPoint<T> {

  /** Called when starts the execution of the associated {@link Task}. Its {@link TaskId} is passed by parameter. */
  public void start(TaskId taskId);
  
  /** Manages a {@link Task} processing result. */
  public <U extends T> void manage(TaskId taskId, U result);

  /** Manages a collection of results of the {@link Task} processing. */
  public <U extends T> void manage(TaskId taskId, Collection<U> result);

  /** Manages an {@link Exception} emitted during the {@link Task} processing. */
  public void manage(TaskId taskId, Exception exception);
  
  /** Called when the associated {@link Task} processing has ended. Its {@link TaskId} is passed by parameter. */
  public void finish(TaskId taskId);

  /** Sets an {@link ReturnPointObserver} that will receive notification of the {@link ReturnPoint} activity. */ 
  public void setObserver(ReturnPointObserver observer);
}
